
 using System;
 using System.Collections;
    using System.Web;
    using System.Collections.Generic;
    using MySql.Data.MySqlClient;   
 using System.ComponentModel; 
    
    
[System.ComponentModel.DataObject]
    public partial class banners_wide 
 {
 #region["Variables"]
   
   
    
                  private int _idBannersWide;
                                
    
                  private int _posicion;
                                
    
                       private string _imagen;
                           
    
                       private string _url;
                           
    
                       private string _nombre;
                           
    
                                      private bool _libre;
            
  
 #endregion
 
 
 #region["Propiedades"]
 
 
       // for the objectDataSource
    [DataObjectField(true,true)]
           
                   public int idBannersWide
                  {
                   get {return _idBannersWide;}
                   set {_idBannersWide = value;}
                  }
                                
      
      
                   public int posicion
                  {
                   get {return _posicion;}
                   set {_posicion = value;}
                  }
                                
      
      
                             public string imagen
                  {
                   get {return _imagen;}
                   set {_imagen = value;}                   
                  }
                      
      
      
                             public string url
                  {
                   get {return _url;}
                   set {_url = value;}                   
                  }
                      
      
      
                             public string nombre
                  {
                   get {return _nombre;}
                   set {_nombre = value;}                   
                  }
                      
      
      
                                      public bool libre
                 {
                     get { return _libre; }
                     set { _libre = value; }
                 }
         
      
        
        
         
          
    
    
    #endregion
   
    public banners_wide()
  {
  }

    public static void Delete(int idBannersWide)
    {
        string sqlt;
        dbClass db = new dbClass(ctes.conStringAdoGeneral);
        try { 
        sqlt = " delete from banners_wide ";
        sqlt += " where 1!=0";  
        
                                                                 sqlt += " and idBannersWide=" + sf.cadena(idBannersWide);
                                                                                                               db.ejecutar(sqlt);
           }
           catch (Exception ex)
           {
               // Argument is optional, no "When" keyword 
           }
           finally
           {
               db.Dispose();
           }

    }
    public static string Insert(banners_wide objbanners_wide)
    {
            
        System.Text.StringBuilder sqlt = new System.Text.StringBuilder();
        string retorno = "";
        dbClass db = new dbClass(ctes.conStringAdoGeneral);
        MySqlDataReader reg;
        try
        {
        sqlt.Append( " insert into banners_wide ( posicion,imagen,url,nombre,libre )"); 
        sqlt.Append( " values (");
                       
      
                   sqlt.Append(sf.entero(objbanners_wide.posicion) + "  , ") ;
                                                               
       
                 
      
                                    sqlt.Append( sf.cadenaMySql(objbanners_wide.imagen) + "  , ") ;
                                             
       
                 
      
                                    sqlt.Append( sf.cadenaMySql(objbanners_wide.url) + "  , ") ;
                                             
       
                 
      
                                    sqlt.Append( sf.cadenaMySql(objbanners_wide.nombre) + "  , ") ;
                                             
       
                 
      
                                                               sqlt.Append( sf.entero(objbanners_wide.libre)  + " ");
                  
       
          sqlt.Append(" )");
            db.ejecutar(sqlt.ToString());
            reg = db.sql("select @@identity as id from banners_wide");
            if (reg.Read())
                {
                  retorno = sf.cadena(reg["id"].ToString());
                }
                reg.Close();
            }
                 
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
            return retorno;
       }

// devuelve una lista de banners_wide
 
   public static List< banners_wide > getList()
  {
      List< banners_wide > listabanners_wide = new List< banners_wide >();
            MySqlDataReader reg;
            string sqlt;
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select * from banners_wide";
            reg = db.sql(sqlt);
            while (reg.Read())
                {
                banners_wide pp = new banners_wide();
  
               pp.idBannersWide = sf.entero(reg["idBannersWide"].ToString());
                             
               pp.posicion = sf.entero(reg["posicion"].ToString());
                             
                   pp.imagen = sf.cadena(reg["imagen"].ToString());
                         
                   pp.url = sf.cadena(reg["url"].ToString());
                         
                   pp.nombre = sf.cadena(reg["nombre"].ToString());
                         
                               pp.libre = sf.Bool(reg["libre"].ToString());
                          listabanners_wide.Add(pp);
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                 
            }
            finally
            {
                db.Dispose();
              
            }
            return listabanners_wide;
       }  
 
 
 // devuelve una lista de banners_wide
 
   public static List< banners_wide > getListByBusquedaGeneral(String cadena)
  {
      List< banners_wide > listabanners_wide = new List< banners_wide >();
            MySqlDataReader reg;
            string sqlt;
   string sqlx="";
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select * from banners_wide";
            sqlt += " where 1!=0 and (";      
                                                                                                           sqlt += "  imagen like '%" + cadena + "%'";  
                                                              sqlt += " or url like '%" + cadena + "%'";  
                                                        sqlt += " or nombre like '%" + cadena + "%'";  
                                                                          sqlt  =  sqlt +sqlx;
   sqlt += " )";  
   reg = db.sql(sqlt);
            while (reg.Read())
                {
                banners_wide pp = new banners_wide();   
  
  
           pp.idBannersWide = sf.entero(reg["idBannersWide"].ToString());
                               
  
  
           pp.posicion = sf.entero(reg["posicion"].ToString());
                               
  
  
               pp.imagen = sf.cadena(reg["imagen"].ToString());
                           
  
  
               pp.url = sf.cadena(reg["url"].ToString());
                           
  
  
               pp.nombre = sf.cadena(reg["nombre"].ToString());
                           
  
  
                           pp.libre = sf.Bool(reg["libre"].ToString());
               
               listabanners_wide.Add(pp);
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                 
            }
            finally
            {
                db.Dispose();
              
            }
            return listabanners_wide;
       }  
 
   public static banners_wide getbanners_wide(int idBannersWide)
  {
            banners_wide banners_widex = new banners_wide();
            MySqlDataReader reg;
            string sqlt;
                banners_wide objbanners_wide = new banners_wide();

            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select * from banners_wide";          
            sqlt += " where 1!=0";  
                          
                                                              sqlt += " and idBannersWide=" + sf.cadena(idBannersWide);
                                                                                                                                                                            
                               
                               
                               
                               
                               
               
            reg = db.sql(sqlt);
            if (reg.Read())
            {          
                                       
                                                                           objbanners_wide.idBannersWide = sf.entero(reg["idBannersWide"].ToString());
                                                                                                                                                                                                                
                                         
                                                                           objbanners_wide.posicion = sf.entero(reg["posicion"].ToString());
                                                                                                                                                                                                                
                                         
                                                                                                             objbanners_wide.imagen = sf.cadena(reg["imagen"].ToString());
                                                                                                                                                                              
                                         
                                                                                                             objbanners_wide.url = sf.cadena(reg["url"].ToString());
                                                                                                                                                                              
                                         
                                                                                                             objbanners_wide.nombre = sf.cadena(reg["nombre"].ToString());
                                                                                                                                                                              
                                         
                                                                                                                                                                                                                   objbanners_wide.libre = sf.Bool(reg["libre"].ToString());
                                                                        
                           
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
            return  objbanners_wide ;
       }

 public static bool Update(banners_wide objbanners_wide)
  {
            MySqlDataReader reg;
            System.Text.StringBuilder sqlt = new System.Text.StringBuilder();
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt.Append(" update banners_wide set");
                            sqlt.Append(" posicion=" + sf.cadena(objbanners_wide.posicion)+ ", ") ;
                                                              sqlt.Append(" imagen='" + sf.cadena(objbanners_wide.imagen)+ "', "); 
                                                          sqlt.Append(" url='" + sf.cadena(objbanners_wide.url)+ "', "); 
                                                          sqlt.Append(" nombre='" + sf.cadena(objbanners_wide.nombre)+ "', "); 
                                                                             sqlt.Append(" libre=" + sf.Bool(objbanners_wide.libre) + "', ");
                    
           sqlt.Append(" where 1!=0");          
         
    
           sqlt.Append( " and idBannersWide=" + objbanners_wide.idBannersWide);
                                    
                                            reg = db.sql(sqlt.ToString());
             return (reg!=null);
              }   
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();              
            }
             return true;
       }
  
   
  
  public void Update()
  {
            MySqlDataReader reg;
            System.Text.StringBuilder sqlt = new System.Text.StringBuilder();
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt.Append(" update banners_wide set");
                   
                  sqlt.Append( " posicion=" + sf.cadena(this.posicion) + "," ) ;
                                                
    
            
                           sqlt.Append(" imagen='" + sf.cadena(this.imagen) + "'," );
                                           
    
            
                           sqlt.Append(" url='" + sf.cadena(this.url) + "'," );
                                           
    
            
                           sqlt.Append(" nombre='" + sf.cadena(this.nombre) + "'," );
                                           
    
            
                                              sqlt.Append(" libre=" + sf.cadena(this.libre)  + "," );
                    
    
                 sqlt.Remove(sqlt.Length - 1, 1);
            sqlt.Append(" where 1!=0");          
         
    
           sqlt.Append( " and idBannersWide=" + this.idBannersWide);
                                    
                                             reg = db.sql(sqlt.ToString());
              }   
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
       }

// comprueba si existe
   public static bool exists(int idBannersWide )
  {
           
            MySqlDataReader reg;
            string sqlt;
            bool retorno=false;
           
            dbClass db = new dbClass(ctes.conStringAdoGeneral);
            try
            {
            sqlt = "select * from banners_wide";
            sqlt += " where 1!=0";  
                                                 
                     
                                                              sqlt += " and idBannersWide=" + sf.cadena(idBannersWide);
                                                                                                                                                                                      
                                                                                                                                                                                
            reg = db.sql(sqlt);
            if (reg.Read()) retorno=true;
            else retorno=false;
               
            reg.Close();
            }
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
            return  retorno;
       }
   
 
            public banners_wide(int idBannersWide)
            {
                MySqlDataReader reg;
                string sqlt;
                dbClass db = new dbClass(ctes.conStringAdoGeneral);
                try
                {
                sqlt = "select * from banners_wide";
                sqlt += " where 1!=0"; 
                                                             
                           
                                                                sqlt += " and idBannersWide=" + idBannersWide;
                                                                                                                                                                                                   
                                                                                                                                                                                                                                      reg = db.sql(sqlt);
                if (reg.Read())
                {        
                      
                           this.idBannersWide = sf.entero(reg["idBannersWide"].ToString());
                                                      
     
                      
                           this.posicion = sf.entero(reg["posicion"].ToString());
                                                      
     
                      
                                    this.imagen = sf.cadena(reg["imagen"]);
                                             
     
                      
                                    this.url = sf.cadena(reg["url"]);
                                             
     
                      
                                    this.nombre = sf.cadena(reg["nombre"]);
                                             
     
                      
                                                               this.libre = sf.Bool(reg["libre"]);
                  
     
                           
               }
            reg.Close();
            }
            catch (Exception ex)
            {
                // Argument is optional, no "When" keyword 
            }
            finally
            {
                db.Dispose();
              
            }
       }
  
// funciones extra para campos extra
                                                                                                  
                         
                                                                                                     
                                                                                
                         
                                                                                                     
                                                                                
                         
                                                                                                     
                                                                                
                         
                                                                                                     
                                                                                
                         
                                                                                                     
                                    
}
        